<template>
  <div class="hello">
    <h1>{{ msg }}</h1>

    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      msg: "登录",
      form: {
        name: "",
        password: ""
      }
    };
  },
  methods: {
    onSubmit() {
      this.$axios({
        method: "get",
        url: "http://localhost:8080/user/login",
        params: {
          name: this.form.name,
          password: this.form.password
        }
      }).then(res => {
                  window.localStorage.setItem("name",this.form.name);
          this.$router.push("../activiti");
        // if (res.data.length > 0) {
        //   window.localStorage.setItem("name", res.data[0].name);
        //   this.$router.push("../activiti");
        
        // } else {
        //   this.$message.error("用户名或密码错误");
        //   this.form.name=""
        //   this.form.password=""
        // }
      });
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
